package org.lzuploader.model;

import java.io.Serializable;
import java.util.Comparator;

/** Easily case insensitive comparison between two strings.
 * 
 * @author Emmanuel Cron
 *
 */
public class CaseInsensitiveComparator implements Comparator<String>, Serializable
{
    /** Serial Version UID of this class. */
    private static final long serialVersionUID = 2598812555848168331L;

    /** Compares two strings.
     * This function is case insensitive
     * @param server1 Server name
     * @param server2 Other server name to compare with server1
     * @return <code>-1</code>, <code>0</code> or <code>1</code> as the first argument is less than, equal to, or greater than the second
     */
    @Override
    public int compare(final String server1, final String server2)
    {
        final String server1Name = (String) server1;
        final String  server2Name = (String) server2;
        
        return server1Name.compareToIgnoreCase(server2Name);
    }
}
